Package pl.wendigo.chrome

Contains library main entrypoint class (Browser) responsible for connecting to remote headless Chrome instance, creating and managing targets (web pages).

Browser object can be obtained using Browser.Builder. Then Targets can be created using Browser.target method.

Samples

import pl.wendigo.chrome.Browser
import pl.wendigo.chrome.sync
fun main() { 
   //sampleStart 
   val browser = Browser.builder()
    .withAddress("127.0.0.1:9222")
    .withBlankPage("about:blank")
    .withViewportWidth(1280)
    .withViewportHeight(1024)
    .withEventsBufferSize(128)
    .multiplexConnections(true)
    .incognito(true)
    .build()

// create new Target that will start loading google.com
val target = browser.target(url = "https://google.com")

// enable Page domain events
sync(target.Page.enable())

// wait for the page to load
sync(target.Page.loadEventFired().firstOrError()) 
   //sampleEnd
}
import pl.wendigo.chrome.Browser
fun main() { 
   //sampleStart 
   val browser = Browser.builder()
    .withAddress("127.0.0.1:9222")
    .withBlankPage("about:blank")
    .withViewportWidth(1280)
    .withViewportHeight(1024)
    .withEventsBufferSize(128)
    .multiplexConnections(true)
    .incognito(true)
    .build()

println(browser.browserInfo()) 
   //sampleEnd
}

Types

Browser
Link copied to clipboard
open class Browser : ProtocolDomains, Closeable, AutoCloseable
Creates new browser that allows querying remote Chrome instance for debugging sessions
BrowserInfoDiscoveryFailedException
Link copied to clipboard
class BrowserInfoDiscoveryFailedException(reason: String) : RuntimeException
BrowserInfoDiscoveryFailedException is thrown when there's no possibility to query browser for debugger WebSocket endpoint.
BuildInfo
Link copied to clipboard
data class BuildInfo(version: String, revision: String, branch: String, group: String, name: String)
FlowableBlock
Link copied to clipboard
typealias FlowableBlock<T> = () -> Flowable<T>
SingleBlock
Link copied to clipboard
typealias SingleBlock<T> = () -> Single<T>

Functions

awaitMany
Link copied to clipboard
fun <T> awaitMany(block: FlowableBlock<T>): List<T>
on
Link copied to clipboard
fun <T> on(flowable: Flowable<T>, listener: (T) -> Unit)
sync
Link copied to clipboard
fun <T : Any> sync(single: Single<T>): T
fun <T : Any> sync(block: SingleBlock<T>): T